package com.ruoyi.web.controller.teaching;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.teaching.dto.FocusonRepeateDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teaching.domain.BblFocusOn;
import com.ruoyi.teaching.service.IBblFocusOnService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 重点关注Controller
 * lbj
 * @author ruoyi
 * @date 2023-05-19
 */
@RestController
@RequestMapping("/teaching/focuson")
public class BblFocusOnController extends BaseController
{
    @Autowired
    private IBblFocusOnService bblFocusOnService;

    /**
     * 查询重点关注列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:focuson:list')")
    @GetMapping("/list")
    public TableDataInfo list(BblFocusOn bblFocusOn)
    {
        startPage();
        List<BblFocusOn> list = bblFocusOnService.selectBblFocusOnList(bblFocusOn);
        return getDataTable(list);
    }

    /**
     * 导出重点关注列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:focuson:export')")
    @Log(title = "重点关注", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BblFocusOn bblFocusOn)
    {
        List<BblFocusOn> list = bblFocusOnService.selectBblFocusOnList(bblFocusOn);
        ExcelUtil<BblFocusOn> util = new ExcelUtil<BblFocusOn>(BblFocusOn.class);
        util.exportExcel(response, list, "重点关注数据");
    }

    /**
     * 获取重点关注详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:focuson:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bblFocusOnService.selectBblFocusOnById(id));
    }

    /**
     * 新增重点关注
     */
    @PreAuthorize("@ss.hasPermi('teaching:focuson:add')")
    @Log(title = "重点关注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BblFocusOn bblFocusOn)
    {
        return toAjax(bblFocusOnService.insertBblFocusOn(bblFocusOn));
    }
    /**
     * 学生中心添加关注,判断是否留级
     */
    @PreAuthorize("@ss.hasPermi('teaching:focuson:repeate')")
    @Log(title = "加入关注", businessType = BusinessType.INSERT)
    @PostMapping("/repeate")
    public AjaxResult addFocusonRepeate(@RequestBody FocusonRepeateDto dto)
    {
        return toAjax(bblFocusOnService.addFocusonRepeate(dto));
    }

    /**
     * 修改重点关注
     */
    @PreAuthorize("@ss.hasPermi('teaching:focuson:edit')")
    @Log(title = "重点关注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BblFocusOn bblFocusOn)
    {
        return toAjax(bblFocusOnService.updateBblFocusOn(bblFocusOn));
    }

    /**
     * 删除重点关注
     */
    @PreAuthorize("@ss.hasPermi('teaching:focuson:remove')")
    @Log(title = "重点关注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bblFocusOnService.deleteBblFocusOnByIds(ids));
    }
}
